﻿Imports Microsoft.VisualBasic
Imports System.Xml.Serialization
Imports System.Globalization


<XmlRoot(elementname:="sdnList", NameSpace:="http://tempuri.org/sdnList.xsd")>
Public Class RawOFACXMLEntity
    Implements ISanctionListType

    <XmlElement("publshInformation")>
    Public publishInfo As PublishDate

    Private sdnList As List(Of SDNEntity)
    <XmlElement("sdnEntry")>
    Public Property SDNListProperty() As List(Of SDNEntity)
        Get
            Return sdnList
        End Get
        Set(ByVal value As List(Of SDNEntity))
            sdnList = value
        End Set
    End Property

    Public Class PublishDate
        <XmlElement("Publish_Date")>
        Public publish_date As String
        <XmlElement("Record_Count")>
        Public record_count As Integer

        Public ReadOnly Property getFormatOFACDateTimeStamp As Date
            Get
                Dim resDate As New Date
                Dim resParse = DateTime.TryParseExact(publish_date, _
                "MM/dd/yyyy", CultureInfo.InvariantCulture, _
                DateTimeStyles.None, resDate)

                Return resDate
            End Get
        End Property
    End Class

    Public Class SDNEntity
        <XmlElement("uid")>
        Public uid As Integer
        <XmlElement("sdnType")>
        Public type As String
        <XmlElement("firstName")>
        Public firstName As String
        <XmlElement("lastName")>
        Public lastName As String
        <XmlElement("title")>
        Public title As String
        <XmlElement("remarks")>
        Public remarks As String

        <XmlElement("programList")>
        Public programListEntity As ProgramList
        <XmlElement("idList")>
        Public idListEntity As IDList
        <XmlElement("vesselInfo")>
        Public vesselInfo As VesselInfo
        <XmlElement("akaList")>
        Public akaList As AkaList
        <XmlElement("dateOfBirthList")>
        Public dobList As DoBInfo
        <XmlElement("placeOfBirthList")>
        Public pobList As PoBInfo
        <XmlElement("addressList")>
        Public addrList As AddressInfo
        <XmlElement("nationalityList")>
        Public nationList As NationalityInfo
        <XmlElement("citizenshipList")>
        Public citizenshipList As CitizenshipList

    End Class

    Public Class ProgramList
        <XmlElement("program")>
        Public program As List(Of String)
    End Class

    Public Class IDList
        <XmlElement("id")>
        Public idEntity As List(Of IDInfo)

        Public Class IDInfo
            <XmlElement("uid")>
            Public uid As Integer
            <XmlElement("idType")>
            Public idType As String
            <XmlElement("idNumber")>
            Public idNumber As String
            <XmlElement("idCountry")>
            Public idCountry As String
            <XmlElement("expirationDate")>
            Public expDate As String
            <XmlElement("issueDate")>
            Public issueDate As String

        End Class
    End Class

    Public Class VesselInfo
        <XmlElement("callSign")>
        Public callSign As String
        <XmlElement("vesselType")>
        Public vesselType As String
        <XmlElement("vesselFlag")>
        Public vesselFlag As String
        <XmlElement("vesselOwner")>
        Public vesselVesselOwner As String
        <XmlElement("tonnage")>
        Public tonnage As Integer
        <XmlElement("grossRegisteredTonnage")>
        Public grossReg As Integer
    End Class

    Public Class AkaList
        <XmlElement("aka")>
        Public akaListEntity As List(Of Aka)
        Public Class Aka
            <XmlElement("uid")>
            Public uid As Integer
            <XmlElement("type")>
            Public type As String
            <XmlElement("category")>
            Public category As String
            <XmlElement("lastName")>
            Public lastName As String
            <XmlElement("firstName")>
            Public firstName As String

        End Class
    End Class

    Public Class DoBInfo
        <XmlElement("dateOfBirthItem")>
        Public dobList As List(Of DobDetail)
        Public Class DobDetail
            <XmlElement("uid")>
            Public uid As Integer
            <XmlElement("dateOfBirth")>
            Public dob As String
            <XmlElement("mainEntry")>
            Public mainEntry As String

            Private mainEntryDigit As Integer
            Public ReadOnly Property MainEntryDigitProperty() As Integer
                Get
                    If mainEntry.Equals("true") Then
                        Return 1
                    Else
                        Return 0
                    End If
                End Get
            End Property
        End Class
    End Class

    Public Class PoBInfo
        <XmlElement("placeOfBirthItem")>
        Public pobList As List(Of PoBDetail)
        Public Class PoBDetail
            <XmlElement("uid")>
            Public uid As Integer
            <XmlElement("placeOfBirth")>
            Public pob As String
            <XmlElement("mainEntry")>
            Public mainEntry As String


            Private mainEntryDigit As Integer
            Public ReadOnly Property MainEntryDigitProperty() As Integer
                Get
                    If mainEntry.Equals("true") Then
                        Return 1
                    Else
                        Return 0
                    End If
                End Get
            End Property

        End Class
    End Class

    Public Class AddressInfo
        <XmlElement("address")>
        Public addrList As List(Of AddressDetail)
        Public Class AddressDetail
            <XmlElement("uid")>
            Public uid As Integer
            <XmlElement("address1")>
            Public address1 As String
            <XmlElement("address2")>
            Public address2 As String
            <XmlElement("address3")>
            Public address3 As String
            <XmlElement("city")>
            Public city As String
            <XmlElement("stateOrProvince")>
            Public stateOrProvince As String
            <XmlElement("postalCode")>
            Public postCode As String
            <XmlElement("country")>
            Public country As String
        End Class
    End Class

    Public Class NationalityInfo
        <XmlElement("nationality")>
        Public nationList As List(Of NationalityList)
        Public Class NationalityList
            <XmlElement("uid")>
            Public uid As Integer
            <XmlElement("country")>
            Public country As String
            <XmlElement("mainEntry")>
            Public mainEntry As String
        End Class
    End Class

    Public Class CitizenshipList
        <XmlElement("citizenship")>
        Public citizenList As List(Of Citizenship)
        Public Class Citizenship
            <XmlElement("uid")>
            Public uid As Integer
            <XmlElement("country")>
            Public country As String
            <XmlElement("mainEntry")>
            Public mainEntry As String
        End Class
    End Class

    Public Function GetTypes() As sanctionListType Implements ISanctionListType.GetTypes
        Return sanctionListType.OFAC
    End Function
End Class
